/* 
 * File:   main.cpp
 * Author: chaterolas
 *
 * Created on 24 de junio de 2009, 04:46 PM
 */

#include "primitives/primitive.h"


#include <stdlib.h>
#include <iostream>

#include "base/vector3d.h"
#include "base/ray.h"
#include "base/material.h"
#include "primitives/sphere.h"
#include "primitives/plane.h"
#include "raytracer/camera.h"
#include "raytracer/scene.h"
#include "primitives/pointlight.h"
#include "primitives/arealight.h"
#include "raytracer/raytracer.h"

using namespace std;

/*
 *  Hardcode scene example
 */
int main(int argc, char** argv) {

    cout << "Hola Mundo!" << endl;

    
    /* Render Test */
    Camera *cam = new Camera(0.0,2.0,-2.0, 0.0,-1.0,1.0);

    Scene *scn = new Scene("example_render_01", 800, 600, 3, cam);

    Material *m = new Material(0.45,0.5,0.72, .5, .95, .51, .7, .1, .5);
    Sphere *s = new Sphere(m, 0.0,0.0,4.0, 2.0);
    scn->addPrimitive(s);

    Material *m1 = new Material(0.3,0.12,0.32, .32, .95, .25, .7, .1, .5);
    Sphere *s1 = new Sphere(m1, 0.0,0.0,-2.0, 2.0);
    scn->addPrimitive(s1);

    Material *m3 = new Material(0.4,0.57,0.25, .32, .95, .25, .7, .1, .5);
    Sphere *s2 = new Sphere(m3, 4.0,0.0,1.0, 2.0);
    scn->addPrimitive(s2);

    Material *m4 = new Material(0.11,0.62,0.44, .32, .95, .25, .7, .1, .5);
    Sphere *s3 = new Sphere(m4, -4.0,0.0,1.0, 2.0);
    scn->addPrimitive(s3);

    Material *m2 = new Material(0.3,0.62,0.12, .3, .95, .2, .7, .1, .5);
    Plane *p = new Plane(m2, 0.0,-2.0,0.0, 0.0,1.0,0.0);
    scn->addPrimitive(p);    

    AreaLight *a = new AreaLight(1.0,1.0,1.0, 0.0,5.0,1.0, 0.0,-1.0,0.0, 0.5, 5.0, 3);
    scn->addPrimitive(a);    

    scn->seal();

    RayTracer *rt = new RayTracer(scn, 3);
    rt->render();

    delete rt;  

    return (EXIT_SUCCESS);
}

